//
//  DetailThridVC.m
//  HomeFurnishing
//
//  Created by dllo on 16/4/8.
//  Copyright © 2016年 YMing. All rights reserved.
//

#import "DetailThridVC.h"
#import "DetailThrCollectionViewCell.h"
#import "DetailFourthVC.h"
@interface DetailThridVC ()<UICollectionViewDelegate, UICollectionViewDataSource>
@property(nonatomic, retain)UICollectionView *collectionV;
@end

@implementation DetailThridVC

-(void)dealloc
{
    [_collectionV release];
    [_dataArr release];

    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationController.navigationBarHidden = NO;
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"back" style:(UIBarButtonItemStylePlain) target:self action:@selector(goBackVC)];
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    layout.minimumLineSpacing = 10;
    layout.minimumInteritemSpacing = 10;
    layout.sectionInset = UIEdgeInsetsMake(10, 5, 10, 5);
    layout.itemSize = CGSizeMake((SCREEN_WIDTH - 30) /3, 120);
    self.collectionV = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT - 64 - 49) collectionViewLayout:layout];
    self.collectionV.backgroundColor = [UIColor whiteColor];
    self.collectionV.delegate = self;
    self.collectionV.dataSource = self;
    [self.view addSubview:self.collectionV];
    [self.collectionV registerClass:[DetailThrCollectionViewCell class] forCellWithReuseIdentifier:@"DetailThridVCCell"];
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.dataArr.count;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    DetailThrCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"DetailThridVCCell" forIndexPath:indexPath];
    NSString *str = [NSString stringWithFormat:@"http://gooju.cn/dimages/%@_0_w750_h398_m0.jpg",self.dataArr[indexPath.row][@"id"]];
    [cell.imgView sd_setImageWithURL:[NSURL URLWithString:str]];
    return cell;
}

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    DetailFourthVC *VC = [[DetailFourthVC alloc] init];
    VC.widthArr = [self.dataArr mutableCopy];
//    for (NSDictionary *dic in self.dataArr) {
//        [VC.widthArr addObject:dic[@"id"]];
//    }
    VC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:VC animated:YES];
    [VC release];
}
-(void)goBackVC
{
    self.navigationController.navigationBarHidden = NO;
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
